package pkg.commands;
import java.awt.Point;
import pkg.*;
import pkg.networking.*;

@SuppressWarnings("serial")
public class SysCmd extends BaseCommand<Object>{

	
	private SysCmd() {}
	
	public static boolean isSys(Object obj)
	{
		return obj instanceof PlayerJoin;
	}
	public static PlayerJoin playerJoin(String name,int id,Point pt)
	{
		return new SysCmd().new PlayerJoin(name,id,pt);
	}
		class PlayerJoin extends SysCmd {

	    	private String name;
	    	private int id,x,y;
	    	public PlayerJoin(String name,int id,Point pt)
	    	{
	    		x = pt.x;
	    		y = pt.y;
	    		this.id = id;
	    		this.name = name;
	    	}
	    	@Override
			public void execute() {
	    		
	    		System.out.println("Player " + name + " Joined");
				EntityManager manager = (EntityManager)this.getData();
				NetworkedPlayer player = (NetworkedPlayer) manager.createEntity("player");
				player.setUserID(id);
				player.setPosition(x,y);
				player.setName(name);
			}
			
		
		}

	
	@Override
	public void execute() {
		// TODO Auto-generated method stub
		
	}
}
